//
//  UIViewController+DataBind.h
//  DataBind
//
//  Created by Super on 2019/12/16.
//  Copyright © 2019 Super. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "DataBindProtocol.h"
#import "DataBindModel.h"

typedef NS_ENUM(int, BindType) {
    BindViewAndModel = 0,   //双向绑定
    BindViewToModel = 1,    //将View绑定到Model  View对应的value改变会同步到Model
    BindModelToView = 2     //将Model绑定到View  Model对应的value改变会同步到View
};

@interface UIViewController (DataBind) <DataBindProtocol>

//绑定View和Model, 默认为双向绑定
- (void)bindModel:(DataBindModel *)model modelKey:(NSString *)modelKey viewInfo:(NSDictionary *)viewInfo block:(dispatch_block_t)block;

//绑定View和Model
- (void)bindModel:(DataBindModel *)model modelKey:(NSString *)modelKey viewInfo:(NSDictionary *)viewInfo bindType:(BindType)bindType block:(dispatch_block_t)block;

//绑定View和Property, 默认为双向绑定
- (void)bindPropertyWithKey:(NSString *)propertyKey viewInfo:(NSDictionary *)viewInfo block:(dispatch_block_t)block;

//绑定View和Property
- (void)bindPropertyWithKey:(NSString *)propertyKey viewInfo:(NSDictionary *)viewInfo bindType:(BindType)bindType block:(dispatch_block_t)block;

//执行解绑
- (void)unBindWithOldBindInfo:(NSDictionary *)oldBindInfo;

@end
